package com.mwy.springbootrabbitmq.controller;

import com.mwy.springbootrabbitmq.amqp.Sender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class Controller1 {

    @Autowired
    private Sender sender;

    @RequestMapping("/send/{message}")
    @ResponseBody
    public String sendMessage(@PathVariable("message") String message){
        System.out.println("进入发送消息sendMessage方法");
        sender.send(message);
        return "发送消息："+message;
    }

    @RequestMapping("/sendFanout/{message}")
    @ResponseBody
    public String sendMessageFanout(@PathVariable("message") String message){
        System.out.println("进入发送消息sendMessageFanout方法");
        sender.sendFanout(message);
        return "订阅发送消息："+message;
    }

}
